<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取鼠标位置</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }
    </style>
    <script>
        function f1() {
            console.log("鼠标x轴坐标:" + event.clientX);
            console.log("鼠标y轴坐标:" + event.clientY);
        }
    </script>
</head>
<body>
<div style="width: 200px;height: 100px;background-color: red;" onmousemove="f1()"></div>
</body>
</html>